package com.pcbly.web.servlet;

import java.io.IOException;


import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GetImageServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4115417022612061453L;
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
	{
//		OutputStream ops = response.getOutputStream();
		Image image = new Image();
		
		ImageIO.write(image.creatImage(), "JPEG", response.getOutputStream());
		request.getSession().setAttribute("rand",Image.sRand);
		//System.out.println("Image.sRand=" + Image.sRand);
		
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
	{
		doPost(request, response);
	}

}
